[Port to dtq-dev] static pages - SSR render; 404 behavior#1241
Open
kosarko wants to merge 2 commits intodataquest-dev:dtq-devfrom
Open
[Port to dtq-dev] static pages - SSR render; 404 behavior#1241kosarko wants to merge 2 commits intodataquest-dev:dtq-devfrom
kosarko wants to merge 2 commits intodataquest-dev:dtq-devfrom
Conversation
* Add src/static-files to build assets Update angular.json to include "src/static-files" in the build assets array so files placed there are copied into the build output. This ensures additional static resources are available at runtime without changing code paths. * Support namespaced/SSR HTML loading; add tests Update HtmlContentService to compose namespaced URLs, build runtime absolute URLs when running on the server (REQUEST/PLATFORM_ID), and centralize HTTP text fetching via getHtmlContent. Ensure APP_CONFIG ui.nameSpace is respected and handle absolute URLs and existing namespace prefixes. Add comprehensive unit tests (html-content.service.spec.ts) covering namespaced/default paths, locale fallback, and error handling. Adjust static-page.component.spec.ts to use a RouterMock with configurable route and add a test asserting the service is called with the route's HTML filename. (cherry picked from commit 4eadd8b)
* Show 404 error for missing static pages
Updated StaticPageComponent to display an inline 404 error message when a static page is not found, matching the PageNotFoundComponent design. Added translations for the new 404 messages in both English and Czech, and set the server response status to 404 for SSR. Removed legacy error page loading logic and updated tests to mock the new ServerResponseService dependency.
* Improve static page loading and error handling
Refactors static page loading to use a new contentState property ('loading', 'found', 'not-found') for clearer UI state management and error handling. Enhances HtmlContentService with cache-busting and robust fallback logic for localized HTML content. Updates tests and template to reflect new state handling and ensures change detection is triggered after content load or error.
* Use any-cast for changeDetector spies
Replace bracket-indexing (component['changeDetector']) with (component as any).changeDetector in static-page.component.spec.ts. This updates three occurrences in the change-detection tests so TypeScript accepts spying on detectChanges without index-signature errors.
* Make cache-bust deterministic & refactor tests
Use a deterministic cache-bust parameter in HtmlContentService.appendCacheBust (avoid Date.now()) and avoid adding the param if it already exists — this keeps the behavior SSR-safe and cache-friendly. Refactor StaticPageComponent unit tests: allow setupTest to accept undefined HTML, return the mocked responseService, and simplify tests by reusing setupTest to remove duplicated test setup code.
* Add loading indicator and error logging
Show a loading spinner while static page content is fetched and add console.error logging on load failures (includes fileName and URL) to aid debugging. Also simplify HtmlContentService by removing a redundant refetch-on-empty response path that caused an extra network request and special-case 404 handling; a 200 now consistently returns the response body (or empty string). UI behavior for not-found responses remains unchanged.
* Use hourly cache-busting query param
Replace the fixed cache-bust value ('1') with a dynamic hourly value computed from Date.now()/3600000. This appends a changing query parameter so responses are refreshed hourly (reducing stale content) while keeping the existing query-separator logic intact. Removed the prior comment about a deterministic SSR-safe value.
* We don't need to manually duplicate static files
when fallback is working correctly
* Refactor HTML loading, add loading state & tests
Remove cache-busting retry logic from HtmlContentService and simplify loadHtmlContent to a single fetch attempt (returning content on 200, undefined otherwise). Update service unit tests to expect fewer HTTP calls and to not rely on cacheBust query params. Add loading-state handling in StaticPageComponent (reset stale not-found to loading, clear htmlContent at init) and adjust template to avoid rendering the 404 block while async content is pending. Enhance component tests: introduce a createDeferred helper, use fixture.whenStable/detectChanges instead of awaiting ngOnInit directly, and add tests for delayed content resolution and resetting stale not-found state.
* Trigger CI rebuild
* Use fakeAsync and tick in cc-license spec
Wrap the 'getCcLicenseLink' unit test in fakeAsync, add tick(350) and fixture.detectChanges() so the debounced observable has time to emit before the assertion. This ensures the async debounce behavior is handled reliably in the spec.
* fixed failing test
repeat the pattern that the other tests have
---------
Co-authored-by: Ondrej Kosarko <kosarko@ufal.mff.cuni.cz>
(cherry picked from commit 4a00c7d)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of ufal#103 and ufal#97 by @amadulhaxxani to
dtq-dev.